﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace landlord2lib
{
    [DataContract]
    public class Card : IComparable<Card>
    {
        [DataMember]
        protected CardKind? m_kind;
        [DataMember]
        protected CardPoint m_point;
        [DataMember]
        protected CardPoint m_comparePoint;

        public Card(CardKind? kind, CardPoint point)
        {
            m_kind = kind;
            m_point = point;
            m_comparePoint = point;
        }

        public CardKind? Kind
        {
            get { return m_kind; }
        }

        public CardPoint Point
        {
            get { return m_point; }
        }

        public virtual bool IsJoker
        {
            get { return m_point == CardPoint.CardGJoker || m_point == CardPoint.CardJoker; }
        }

        public virtual int CompareTo(Card other)
        {
            return (int)ComparePoint - (int)other.ComparePoint;
        }

        public virtual CardPoint ComparePoint
        {
            get
            {
                return IsJoker ? m_comparePoint : m_point;
            }
            set
            {
                m_comparePoint = value;
            }
        }

        public virtual void Reset()
        {
            m_comparePoint = m_point;
        }
    }
}
